﻿<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>持名法州主页</title>
    <%--引入日期控件--%>
    <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/IconExtension.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
    <%--引入echarts脚本--%>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/echarts.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/china.js"></script>
    <%--引入goeasy脚本--%>
    <script src="https://cdn-hangzhou.goeasy.io/goeasy.js"></script>



    <script type="text/javascript">
        <!--菜单处理-->
        $(function(){
            // 1.获取数据库数据 ajax
            $.ajax({
                url:"${pageContext.request.contextPath}/menu/selectMenus",
                type:"get",
                dataType:"JSON",
                success:function (data) {
                        // 2.对数据做展示 循环
                        // 循环参数详细 被循环数据（集合数据） 函数 函数参数 1.下标 2.被遍历到的数据
                    $.each(data,function(index,first){
                        //console.log(first)
                        // 3.取出一级菜单中的二级菜单数据 再child属性中
                        var c = "";
                        //这里出现错误
                        $.each(first.menuList,function (index1,second) {
                            //console.log(first.menuList);
                            c +="<div style='text-align: center'><a href='#' class='easyui-linkbutton' data-options=\"iconCls:'icon-search',plain:true\" onclick=\"addTabs('" +second.menuName+ "','" + second.menuUrl+ "')\">" + second.menuName+ "</a></div>";

                        });
                        $('#myAccordion').accordion('add', {
                            title: first.menuName,
                            content: c,
                            selected: false
                        });
                    })
                }
            });


        });

        function addTabs(name,url){
            //判断选项卡是否存在
            var isExists=$("#myTabs").tabs("exists",name);

            if(isExists){
                //存在，选中
                $("#myTabs").tabs("select",name);
            }else{
                //不存在，新建
                $('#myTabs').tabs('add',{
                    title:name,
                    selected:true,
                    closable:true,
                    //content:"我是大坏蛋！！！",
                    href:"${pageContext.request.contextPath}"+url

                });
            }

        }


    </script>

</head>
<body class="easyui-layout">
<div data-options="region:'north',split:true" style="height:60px;background-color:  #5C160C">
    <div style="font-size: 24px;color: #FAF7F7;font-family: 楷体;font-weight: 900;width: 500px;float:left;padding-left: 20px;padding-top: 10px" >持名法州后台管理系统</div>
    <div style="font-size: 16px;color: #FAF7F7;font-family: 楷体;width: 300px;float:right;padding-top:15px">欢迎您:xxxxx &nbsp;<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改密码</a>&nbsp;&nbsp;<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-01'">退出系统</a></div>
</div>
<div data-options="region:'south',split:true" style="height: 40px;background: #5C160C">
    <div style="text-align: center;font-size:15px; color: #FAF7F7;font-family: 楷体" >&copy;百知教育 htf@zparkhr.com.cn</div>
</div>

<div data-options="region:'west',title:'导航菜单',split:true" style="width:220px;">
    <div id="myAccordion" class="easyui-accordion" data-options="fit:true">

    </div>
</div>
<div data-options="region:'center'">
    <div id="myTabs" class="easyui-tabs" data-options="fit:true,narrow:true,pill:true">
        <div title="主页" data-options="iconCls:'icon-neighbourhood',"  style="background-image:url(image/shouye.jpg);background-repeat: no-repeat;background-size:100% 100%;"></div>
    </div>
</div>
</body>
</html>